--[[
Author: your name
Date: 2020-12-01 11:04:29
LastEditTime: 2020-12-04 10:45:42
LastEditors: your name
Description: In User Settings Edit
FilePath: \Lua\Net\tacticsHandler.lua
--]]
require "proto/tactics/message/ReqTacticsActivateMessage"
require "proto/tactics/message/ReqTacticsListMessage"
require "proto/tactics/message/ReqTacticsOpenMessage"
require "proto/tactics/message/ReqTacticsUpLevelMessage"

tacticsHandler = tacticsHandler or {};

function tacticsHandler.receiveTacticsActivate(msg)
    --log("partnerHandler.receiveTacticsActivate");
    --dataTable.PrintTable(msg);
    if msg.state == 0 then
        logicMgr.TacticsManager.setTacticsInfo(msg.tacticsInfo[1]);
        FireEvent(Config.EventType.Fresh_Tactics);
        UISysTips.AddMsg(getLanguage("Character_Tips4"));
    end
end

function tacticsHandler.receiveTacticsList(msg)
    --log("partnerHandler.receiveTacticsList");
    --dataTable.PrintTable(msg);
    if msg.state == 0 then
        logicMgr.TacticsManager.setTacticsInfoList(msg.tacticsList,msg.currTacticsId);
    end
end

function tacticsHandler.receiveTacticsOpen(msg)
    --log("partnerHandler.receiveTacticsOpen");
    --dataTable.PrintTable(msg);
    if msg.state == 0 then
        logicMgr.TacticsManager.setTacticsUse(msg.tacticsId);
        FireEvent(Config.EventType.Fresh_Tactics);
    end
end

function tacticsHandler.receiveTacticsUpLevel(msg)
    --log("partnerHandler.receiveTacticsUpLevel");
    --dataTable.PrintTable(msg);
    if msg.state == 0 then
        logicMgr.TacticsManager.setTacticsInfo(msg.tacticsInfo[1]);
        FireEvent(Config.EventType.Fresh_Tactics);
        UISysTips.AddMsg(getLanguage("Character_Tips3"));
    end
end

function tacticsHandler.sendTacticsActivate(tacticsId)
    local req = ReqTacticsActivateMessage.New();
    req.tacticsId = tacticsId;
    sendReqMessage(req);
end

function tacticsHandler.sendTacticsList()
    local req = ReqTacticsListMessage.New();
    sendReqMessage(req);
end
 
function tacticsHandler.sendTacticsOpen(tacticsId)
    local req = ReqTacticsOpenMessage.New();
    req.tacticsId = tacticsId;
    sendReqMessage(req);
end

function tacticsHandler.sendTacticsUpLevel(tacticsId,level)
    local req = ReqTacticsUpLevelMessage.New();
    req.tacticsId = tacticsId;
    req.level = level;
    sendReqMessage(req);
end
 